using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Specialized;
using System.Reflection;
using System.IO;
using System.Xml;
using System.Windows.Forms;
using PVID_UHF_CE_Application;

namespace SampleUHFAt900
{
     public static class MobileConfiguration   
     {
         public static NameValueCollection Settings;
         static MobileConfiguration()
         {
             try
             {


                 string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
                 //MessageBox.Show(appPath);
                 string configFile = Path.Combine(appPath, "App.config");
                 if (!File.Exists(configFile))
                 {
                     throw new FileNotFoundException(string.Format("Application configuration file '{0}' not found.", configFile));
                 }
                 XmlDocument xmlDocument = new XmlDocument();
                 xmlDocument.Load(configFile);
                 XmlNodeList nodeList = xmlDocument.GetElementsByTagName("appSettings");
                 Settings = new NameValueCollection();
                 foreach (XmlNode node in nodeList)
                 {
                     foreach (XmlNode key in node.ChildNodes)
                     {
                         Settings.Add(key.Attributes["key"].Value, key.Attributes["value"].Value);
                     }
                 }
             }
             catch (Exception ex)
             {
                 AppLogWriter.WriteErrorLog("MC Error: " + ex.Message);
                 MessageBox.Show("MC: " + ex.Message);
             }
         }
     }
}
